package demo;

import dao.NewsDao;
import dao.impl.MySqlDaoFactory;
import dao.impl.SimpleDaoFactory;
import service.impl.NewsServiceImpl;

public class NewsMain {
    public static void main(String[] args) {
//        //示例1-4
//        NewsDao dao= SimpleDaoFactory.getInstance("mysql");
//        NewsServiceImpl service=new NewsServiceImpl();
//        service.setDao(dao);

//        //示例5
//        AbstractFactory factory=new MySqlDaoFactory();//改变具体工厂可创建不同产品
//        NewsDao dao=factory.getInstance();
//        NewsServiceImpl service=new NewsServiceImpl();
//        service.setDao(dao);

//        //示例6
//        Buyer buyer=new IntermediaryImpl(new RealBuyer());
//        String result=buyer.havealook();
//        System.out.println(result);

//        //示例7
//        RealBuyer buyer=new IntermediarySubclass();
//        String result=buyer.havealook();
//        System.out.println(result);

//        //示例8
//        Buyer buyer=IntermediaryJdkProxyFactory.create(new RealBuyer());
//        String result=buyer.havealook();
//        System.out.println(result);

        //示例9
        RealBuyer buyer=IntermediaryCglibProxyFactory.create(RealBuyer.class);
        String result=buyer.havealook();
        System.out.println(result);
    }
}
